package com.hup.joystick.model.joystick;

import com.hup.joystick.constant.DeviceKey.KeyType;
import com.hup.joystick.constant.DeviceKey.NativeKeys;
import com.hup.joystick.service.jna.DIJoyState2;

/**
 * @author hugan
 * @date 2020/10/23
 */
public class NativeKey {

    /**
     * {@link KeyType}
     */
    public final int type;
    /**
     * {@link DIJoyState2}的属性值对应的按键字符串{@link NativeKeys}
     */
    public final String key;
    /**
     * {@link DIJoyState2}的属性值;
     * 按钮:按钮index
     *
     */
    public long nativeValue;

    private NativeKey(int type, String key) {
        this.type = type;
        this.key = key;
    }

    public static NativeKey button(String key, int nativeValue) {
        NativeKey res = new NativeKey(KeyType.BTN, key);
        res.nativeValue = nativeValue;
        return res;
    }

    public static NativeKey arrow(String key, long nativeValue) {
        NativeKey res = new NativeKey(KeyType.ARROW, key);
        res.nativeValue = nativeValue;
        return res;
    }

    public static NativeKey stick(String key, long nativeValue) {
        NativeKey res = new NativeKey(KeyType.STICK, key);
        res.nativeValue = nativeValue;
        return res;
    }

}
